<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:r="http://ricchieri.com/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>


	<ui:composition template="../../templates/commonLayoutReservation.xhtml">
		<ui:define name="title">#{msg.titleOther}</ui:define>
		<ui:define name="content">
					
			<h:form id="addSchedule" style="height:50%">			
				<h2>#{msg.passengerList}</h2>
				<p:messages showDetail="false" autoUpdate="true" closable="false"/>						
				<p:wizard id="tabView" style="margin-top:15px" showStepStatus="true" showNavBar="false" widgetVar="wiz"> 
					
					<p:tab id="tab1" title="#{msg.scheduleCalendar}">
						<p:panel> 
							<h:outputLabel value="#{msg.capacity}" style="text-align:center; width:100%"/>
							<p:panelGrid columns="4" style="margin-bottom:10px;text-align: center;">
								<p:outputPanel>
									<span class="full-capacity">Empty</span>
									<h:outputLabel value="#{msg.fullCapacity}"/>
								</p:outputPanel>
								
								<p:outputPanel>
									<span class="low-capacity">Empty</span>
									<h:outputLabel value="#{msg.lowCapacity}"/>
								</p:outputPanel>
								
								<p:outputPanel>
									<span class="medium-capacity">Empty</span>
									<h:outputLabel value="#{msg.mediumCapacity}"/>
								</p:outputPanel>
								
								<p:outputPanel>
									<span class="high-capacity">Empty</span>
									<h:outputLabel value="#{msg.highCapacity}"/>
								</p:outputPanel>
							</p:panelGrid>
	
							<h:panelGrid columns="2">
								<h:outputLabel value="#{msg.tripOrientation}" />
								<p:selectOneMenu value="#{viewScheduleStatusMB.scheduleCharterFilter.trip}">
									<f:selectItems value="#{viewScheduleStatusMB.trips}" />
									<p:ajax listener="#{viewScheduleStatusMB.changeTrip}" update=":addSchedule"/>
								</p:selectOneMenu>
							</h:panelGrid>
							<p:schedule id="schedule" value="#{viewScheduleStatusMB.scheduleLazyModel}" draggable="false" resizable="false" widgetVar="myschedule" style="padding-top:15px;" timeFormat="HH:mm">  
			       				<p:ajax event="eventSelect" listener="#{viewScheduleStatusMB.onEventSelect}" update="eventDetails" oncomplete="eventDialog.show()" /> 
							</p:schedule>				
						</p:panel>
						
						<p:dialog widgetVar="eventDialog" header="#{msg.eventDetails}" showEffect="clip" hideEffect="clip" maximizable="false" minimizable="false" resizable="false">
					        <h:panelGrid id="eventDetails" columns="2">
								    <h:outputLabel style="font-weight:bold" value="#{msg.date}" />
						            <h:outputLabel value="#{viewScheduleStatusMB.formatDate(viewScheduleStatusMB.event.scheduleCharter.schedule.date)}" />
						            
						            <h:outputLabel style="font-weight:bold" value="#{msg.time}" />
						            <h:outputLabel value="#{viewScheduleStatusMB.event.scheduleCharter.schedule.time}" />
						
									<h:outputLabel style="font-weight:bold" value="#{msg.charterNumber}" />
									<h:outputLabel value="#{viewScheduleStatusMB.event.scheduleCharter.charter.charterNumber}" />  
						
									<h:outputLabel style="font-weight:bold" value="#{msg.charterType}"/>
									<h:outputLabel value="#{viewScheduleStatusMB.obtainDescription(viewScheduleStatusMB.event.scheduleCharter.charter.charterType.description)}" /> 
	
									<h:outputLabel style="font-weight:bold" value="#{msg.charterPlaces}"/>
									<h:outputLabel value="#{viewScheduleStatusMB.event.scheduleCharter.charter.places}" />  
									 
									<h:outputLabel style="font-weight:bold" value="#{msg.reservationsTotal}"/>
									<h:outputLabel value="#{viewScheduleStatusMB.event.scheduleCharter.quantityReserved}" />  
						
									<h:outputLabel style="font-weight:bold" value="#{msg.scheduleDriver}"/>
									<h:outputLabel value="#{viewScheduleStatusMB.event.scheduleCharter.user.getFullName()}" /> 					
					        </h:panelGrid>
							<center>
								<p:commandButton value="#{msg.select}" update="@form" action="#{viewScheduleStatusMB.showTravelDetails(viewScheduleStatusMB.event)}" oncomplete="wiz.next();"/>
							</center>
					    </p:dialog>
					    
					</p:tab>
					<p:tab id="tab2" title="#{msg.templateReservation}">
						<p:panel>
							<h:panelGrid columns="2">
								<h:outputLabel style="font-weight:bold" value="#{msg.date}" />
					            <h:outputLabel value="#{viewScheduleStatusMB.formatDate(viewScheduleStatusMB.scheduleCharter.schedule.date)}" />
					            
					            <h:outputLabel style="font-weight:bold" value="#{msg.time}" />
					            <h:outputLabel value="#{viewScheduleStatusMB.scheduleCharter.schedule.time}" />
					            
					            <h:outputLabel style="font-weight:bold" value="#{msg.tripOrientation}" />
					            <h:outputLabel value="#{viewScheduleStatusMB.scheduleCharter.trip.getFormatTrip()}" />
					
								<h:outputLabel style="font-weight:bold" value="#{msg.charterNumber}" />
								<h:outputLabel value="#{viewScheduleStatusMB.scheduleCharter.charter.charterNumber}" />  
								
								<h:outputLabel style="font-weight:bold" value="#{msg.charterType}"/>
								<h:outputLabel value="#{viewScheduleStatusMB.obtainDescription(viewScheduleStatusMB.scheduleCharter.charter.charterType.description)}" /> 
					
								<h:outputLabel style="font-weight:bold" value="#{msg.charterPlaces}"/>
								<h:outputLabel value="#{viewScheduleStatusMB.scheduleCharter.charter.places}" />   
					
								<h:outputLabel style="font-weight:bold" value="#{msg.scheduleDriver}"/>
								<h:outputLabel value="#{viewScheduleStatusMB.scheduleCharter.user.getFullName()}" />
							</h:panelGrid>
							
							<br/>
							<h2>#{msg.reservations}</h2>
							<p:dataTable var="reservartion" value="#{viewScheduleStatusMB.orderReservations()}" 
					     	 		style="padding-top:15px" id="reservationTable"  rowStyleClass="#{viewScheduleStatusMB.isAfterLastUpdate(reservartion) ? 'new-event' : null}"
					     	 		paginatorPosition="bottom" emptyMessage="#{msg.noRecordsFound}">
					 
					 		 		<p:column headerText="#{msg.full_name}" style="width:30%">  
						            	<h:outputText value="#{reservartion.user.getFullName()}" />   
					        		</p:column> 
					 
					 				<p:column headerText="#{msg.documentType}" style="width:7%">  
						            	<h:outputText value="#{viewScheduleStatusMB.obtainDescription(reservartion.user.documentType.description)}" />   
					        		</p:column> 
					        		
							        <p:column headerText="#{msg.documentNum}" style="width:20%">  
						            	<h:outputText value="#{reservartion.user.dni}" />   
					        		</p:column> 
					        		
					        		<p:column headerText="#{msg.reservationType}" style="width:20%">  
					        			<h:outputLabel value="#{viewScheduleStatusMB.obtainDescription(reservartion.reservationType.description)}"/>	
					        		</p:column> 
					        		
					        		<p:column headerText="#{msg.tripPrice}" style="width:20%">  
					        			<h:outputLabel value="#{reservartion.cost}"/>
					        		</p:column> 
					        		
					        		<p:column headerText="#{msg.reservationStatus}" style="width:20%">  
						            	<h:outputText value="#{viewScheduleStatusMB.getStatusDescription(reservartion.cancel)}" />   
					        		</p:column>
							</p:dataTable>
							
							<h:panelGrid columns="2" style="text-align:center; margin-top:10px;" id="scheduleOptions">
					        	<r:commandLinkCustom id="export" action="#{viewScheduleStatusMB}" method="downloadReport" icon="icon-cloud-download" message="#{msg.download}" style="font-size:14px" ajax="false" update="scheduleOptions" disabled="#{viewScheduleStatusMB.scheduleCharter.getActiveReservations().size() == 0}"/>
								<p:commandLink styleClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only button-action" style="font-size:14px" oncomplete="sendMessage.show();" disabled="#{viewScheduleStatusMB.scheduleCharter.getActiveReservations().size() == 0}">
									<span class="ui-button-text ui-c"><i class="icon-envelope"></i><r:space/><r:space/>#{msg.sendNotification}</span>
								</p:commandLink>
				
					     	 	<p:dialog id="confirmDialogDel" header="#{msg.notification}" widgetVar="sendMessage" showEffect="clip" hideEffect="clip" maximizable="false" minimizable="false" resizable="false" width="50%">
					     	 	
					     	 		<h:panelGrid columns="1" id="sendMessagePanel">
					     	 			<h:inputTextarea rows="12" cols="10" style="width:100%" value="#{viewScheduleStatusMB.obtainTextToSend()}" id="textToSend" readonly="true" autoResize="false"/>
					     	 	 		<p:inputTextarea rows="12" style="width:100%" id="message" value="#{viewScheduleStatusMB.message}" autoResize="false"  title="#{component.valid ? '' : manageBean.getErrorMessage(component.clientId)}">
					     	 	 			<p:ajax event="keyup" update="textToSend" /> 
					     	 	 		</p:inputTextarea>
										<p:message id="messageMsg" for="message"/>
					     	 	 	</h:panelGrid>
							    	<div style="margin-top:10px;text-align:center">
								        <p:commandButton id="decline" value="#{msg.cancelButton}" oncomplete="sendMessage.hide()" style="margin-right:10px;" />     
								        <p:commandButton id="confirm" value="#{msg.sendButton}" style="margin-left:10px;" action="#{viewScheduleStatusMB.sendNotification()}" oncomplete="handleRequest(xhr, status, args)" update="sendMessagePanel"/>
							    	</div>      
							    </p:dialog>  
							    
							    
							    <script type="text/javascript">
									function handleRequest(xhr, status, args) {
								        if(args.validationFailed || !args.isValid) {
											return;
								        } else {
								        	sendMessage.hide();
								        }
								    }
								</script>	
							</h:panelGrid>
						</p:panel>
					
						<div style="text-align:right; margin-top:10px" >					
							<p:commandLink update="@form" onclick="wiz.back();" styleClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only button-action">
								<span class="ui-button-text ui-c"><i class="icon-arrow-left"></i><r:space/><r:space/>#{msg.previous}</span>
							</p:commandLink>
						</div>
					</p:tab>
				</p:wizard>		
				
					
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>
